
import pyautogui
import cv2
import time
import pyautogui
import numpy as np
import pygetwindow as gw
from PIL import Image
from win32gui import GetForegroundWindow, GetWindowRect

# 等待游戏加载完毕
time.sleep(3)

# 获取当前活动窗口的句柄
hwnd = GetForegroundWindow()
# 获取窗口的位置和大小
left, top, right, bottom = GetWindowRect(hwnd)
# 计算窗口的宽度和高度
width = right - left
height = bottom - top
# while True:
x_start = 0.43
y_start = 0.48
x_offset = 0.045
y_offset = 0.085
# 循环遍历y轴
for i in range(0, 3):
    # 循环遍历x轴
    for j in range(0, 4):
        relative_x = width * (x_start + x_offset * j)
        relative_y = height * (y_start + y_offset * i)
        print("坐标：", relative_x, relative_y)
        # 计算绝对坐标
        absolute_x = left + relative_x
        absolute_y = top + relative_y
        # 移动鼠标到计算出的绝对坐标
        pyautogui.moveTo(absolute_x, absolute_y)
        time.sleep(1)

